<template>
  <div class="box-list-container">
    <div class="box-query-form">
      <el-form :model="queryParam" label-width="auto" label-position="right" :gutter="24">
        <el-row>
          <el-col :xl="8" :lg="8" :md="12" :sm="24">
            <el-form-item label="游戏名称:">
              <el-input v-model="queryParam.gameName" clearable placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24" class="table-search-btn">
            <el-button icon="el-icon-refresh" @click="searchReset">重置</el-button>
            <el-button type="primary" icon="el-icon-search" @click="searchQuery">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="box-table">
      <div class="table-title">
        <div class="table-title-left">
          游戏列表
        </div>
        <div>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd('新增')">新增</el-button>
        </div>
      </div>
      <el-table ref="table" :data="dataSource">
        <el-table-column prop="id" label="ID" width="60" />
        <el-table-column prop="gameName" label="游戏名称" min-width="150" />
        <el-table-column prop="imgUrl" label="游戏图标" min-width="120">
          <template slot-scope="scope">
            <div class="imgList">
              <el-image :src="scope.row.imgUrl" :preview-src-list="[scope.row.imgUrl]" />
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="prefix" label="图片前缀" width="120" />
        <el-table-column prop="topupMode" label="充值方式" width="120" />
        <el-table-column prop="updateTime" label="更新时间" width="150" />
        <el-table-column prop="createTime" label="创建时间" width="150" />
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-button type="text" @click="handleEdit('编辑', scope.row)">编辑</el-button>
            <el-popconfirm title="确定删除吗？" style="margin-left: 10px" @confirm="handleDelete(scope.row[guidFieldName])">
              <el-button slot="reference" type="text" style="color: red;">删除</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
      <div class="box-paging">
        <Pagination
          v-show="ipagination.total > 0"
          layout="total, sizes, prev, pager, next"
          :total="ipagination.total"
          :page.sync="ipagination.pageNum"
          :limit.sync="ipagination.pageSize"
          @pagination="loadData"
        />
      </div>
    </div>
    <handleDialog ref="modalForm" @ok="modalFormOk" />
  </div>
</template>

<script>
import { listMixin } from '@/mixins/listMixin'
import Pagination from '@/components/Pagination'
import handleDialog from './components/handleDialog'

export default {
  components: {
    Pagination,
    handleDialog
  },
  mixins: [listMixin],
  data() {
    return {
      guidFieldName: 'id',
      ipagination: {
        pageNum: 1,
        total: 0
      },
      queryParam: {},
      userInfo: this.$ls.get('USER_INFO') || {},
      url: {
        list: 'gameList.aspx?action=GetList',
        delete: 'gameList.aspx?action=Delete',
        deleteBatch: 'gameList.aspx?action=DeleteBatch'
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
    // 重置
    searchReset() {
      this.queryParam = {}
      this.loadData(1)
    },
    disposeListData(list) {
      this.$ls.set('GAME_LIST', list)
      console.log('重新保存')
      return list || []
    }
  }
}
</script>

<style lang="scss" scoped>
.imgList{
  display: flex;
  // flex-wrap: nowrap;
  .el-image{
    width: 80px;
    height: 80px;
    // margin-right: 5px;
  }
}
</style>

